package com.dragonboat.util;

import lombok.Data;

@Data
public class ResponseResult<T> {
    private int code;
    private String message;
    private T data;

    // 显式定义构造方法（避免 Lombok 泛型问题）
    public ResponseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResponseResult<T> success(T data) {

        return new ResponseResult<>(200, "success", data);
    }

    public static <T> ResponseResult<T> error(String message) {

        return new ResponseResult<>(400, message, null);
    }
    public static ResponseResult<Void> success() {
        return new ResponseResult<>(200, "success", null);
    }
    // 在 ResponseResult 类中添加这个方法
    public static <T> ResponseResult<T> error(int code, String message) {
        return new ResponseResult<>(code, message, null);
    }
}